package com.hxm.appGenealogy.controller;

import com.hxm.appGenealogy.entity.*;
import com.hxm.appGenealogy.service.FamliyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 家族控制器;
 */
@CrossOrigin
@RestController
@RequestMapping("app/family")
public class FamliyController {

    @Autowired
    private FamliyService famliyService;

    @PostMapping("slectByid")
    public ResponDataVo selectByid(@RequestBody Family family) {
        return famliyService.selectByid(family.getId());
    }

    @PostMapping("updateById")
    public ResponDataVo updateById(@RequestBody Family family) {
        return famliyService.updateById(family);
    }
    /**
     * 创建家族;
     * @param family
     * @return
     */
    @PostMapping("insertfaily")
    public ResponDataVo insert(@RequestBody Family family) {
        //创建家族,将顶级的id,设置为创始人;
        family.setTopPeopleId(family.getCreatorPeopleId());
        return famliyService.insert(family);
    }

    @PostMapping("idHaveFamliy")
    public ResponDataVo idHaveFamliy(@RequestBody People people) {
        return famliyService.idHaveFamliy(people);
    }
    /**
     * 加入家族;
     * @param familyVo
     * @return
     */
    @PostMapping("joinFamliy")
    public ResponDataVo joinFamliy(@RequestBody FamilyVo familyVo) {
        return famliyService.joinFamliy(familyVo);
    }
    /**
     * 查询家族人员列表;
     * @param family
     * @return
     */
    @PostMapping("selectFamliypople")
    public ResponDataVo selectFamliyPeople(@RequestBody Family family) {
        return famliyService.selectFamliyPeople(family);
    }
    /**
     * 扫码补坑;
     */
    @PostMapping("qrQit")
    public ResponDataVo qrOit(@RequestBody PeopleVo peopleVo) {
        return famliyService.qrOit(peopleVo);
    }

    /**
     * 添加管理员权限;
     */
    @PostMapping("addjurisdiction")
    public ResponDataVo addJurisdiction(@RequestBody FamilyVo familyVo) {
        return famliyService.addJurisdiction(familyVo);
    }

    /**
     * 添加管理员权限;
     */
    @PostMapping("cancelJurisdiction")
    public ResponDataVo cancelJurisdiction(@RequestBody FamilyVo familyVo) {
        return famliyService.cancelJurisdiction(familyVo);
    }

    /**
     * 根据家族的id,获取家族中的存储照片的大小;
     * @return
     */
    @PostMapping("selectImageSize")
    public ResponDataVo imageSize(@RequestBody Family family) {
        return famliyService.imageSize(family);
    }
}







